import dashboard from "./modules/dashboard";
import setting from "./modules/setting";
import returnVisit from "./modules/returnVisit";
import treatment from "./modules/treatment";
import patient from "./modules/patient";
import BasicLayout from "@/layouts/basic-layout";
import UserSetting from "./modules/userSetting";
import reportForm from "./modules/reportForm";
import infusion from "./modules/Infusion";

/**
 * 在主框架内显示
 */

const frameIn = [
    {
        path: "/",
        redirect: {
            name: "home-dashboard-todoList",
        },
        component: BasicLayout,
        children: [
            {
                path: "index",
                name: "home-index",
                redirect: {
                    name: "home-dashboard-todoList",
                },
            },
            {
                path: "log",
                name: "home-log",
                meta: {
                    title: "前端日志",
                    auth: true,
                },
                component: () => import("@/pages/home/system/log"),
            },
            // 刷新页面 必须保留
            {
                path: "refresh",
                name: "home-refresh",
                hidden: true,
                component: {
                    beforeRouteEnter(to, from, next) {
                        next((instance) =>
                            instance.$router.replace(from.fullPath)
                        );
                    },
                    render: (h) => h(),
                },
            },
            // 页面重定向 必须保留
            {
                path: "redirect/:route*",
                name: "home-redirect",
                hidden: true,
                component: {
                    beforeRouteEnter(to, from, next) {
                        next((instance) =>
                            instance.$router.replace(
                                JSON.parse(from.params.route)
                            )
                        );
                    },
                    render: (h) => h(),
                },
            },
            {
                path: "home/medical",
                name: "home-medical",
                meta: {
                    title: "导医列表",
                    auth: true,
                },
                component: () => import("@/pages/home/medical"),
            },
            {
                path: "home/followuplist",
                name: "home-followuplist",
                meta: {
                    title: "跟进列表",
                    auth: true,
                },
                component: () => import("@/pages/home/followuplist"),
            },
            {
                path: "home/taskList",
                name: "home-taskList",
                meta: {
                    title: "任务列表",
                    auth: true,
                },
                component: () => import("@/pages/home/taskList"),
            },
            {
                path: "home/systemlog",
                name: "home-systemlog",
                meta: {
                    title: "系统日志",
                    auth: true,
                },
                component: () => import("@/pages/home/systemlog"),
            },
            {
                path: "clique/operateReport",
                name: "home-operateRepor",
                meta: {
                    title: "运营报表",
                    auth: true,
                },
                component: () => import("@/pages/clique/operateReport"),
            },
            {
                path: "clique/perfectReport",
                name: "home-perfectReport",
                meta: {
                    title: "完善报表",
                    auth: true,
                },
                component: () => import("@/pages/clique/perfectReport"),
            },
            {
                path: "clique/treatmentReport",
                name: "home-treatmentReport",
                meta: {
                    title: "治疗报表",
                    auth: true,
                },
                component: () => import("@/pages/clique/treatmentReport/index"),
            },
            {
                path: "clique/visitReport",
                name: "home-visitReport",
                meta: {
                    title: "回访报表",
                    auth: true,
                },
                component: () => import("@/pages/clique/visitReport"),
            },
        ],
    },
    dashboard,
    setting,
    returnVisit,
    treatment,
    patient,
    UserSetting,
    reportForm,
    infusion
    // followuplist
];

/**
 * 在主框架之外显示
 */

const frameOut = [
    // 登录
    {
        path: "/login",
        name: "login",
        meta: {
            title: "$t:page.login.title",
        },
        component: () => import("@/pages/account/login"),
    },
    // 注册
    {
        path: "/register",
        name: "register",
        meta: {
            title: "$t:page.register.title",
        },
        component: () => import("@/pages/account/register"),
    },
    // 注册结果
    {
        path: "/register/result",
        name: "register-result",
        meta: {
            auth: true,
            title: "注册结果",
        },
        component: () => import("@/pages/account/register/result"),
    },
];

/**
 * 错误页面
 */

const errorPage = [
    {
        path: "/403",
        name: "403",
        meta: {
            title: "403",
        },
        component: () => import("@/pages/home/system/error/403"),
    },
    {
        path: "/500",
        name: "500",
        meta: {
            title: "500",
        },
        component: () => import("@/pages/home/system/error/500"),
    },
    {
        path: "*",
        name: "404",
        meta: {
            title: "404",
        },
        component: () => import("@/pages/home/system/error/404"),
    },
];

// 导出需要显示菜单的
export const frameInRoutes = frameIn;

// 重新组织后导出
export default [...frameIn, ...frameOut, ...errorPage];
